package com.adams.custom.page.core.service;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.adams.access.db.bean.ViewPanel;
import com.adams.core.exception.BusinessException;

/**
 * 
 * File Name : SQLConstructServie.java
 * 
 * @Description : SQL语句组装接口
 */

public interface SQLConstructServie
{

	public final static String keyWord_equal = "=";
	public final static String keyWord_notEqual = "!=";
	public final static String keyWord_greater = ">";
	public final static String keyWord_less = "<";
	public final static String keyWord_notGreater = "<=";
	public final static String keyWord_notLess = ">=";
	public final static String keyWord_like = "like";
	public final static String keyWord_in = "in";
	public final static String keyWord_between = "between";
	public final static String keyWord_is = "is";

	public final static String ORDER_DESC = "desc";
	public final static String ORDER_ASC = "asc";

	/**
	 * Description : 构造查询总数sql语句
	 * 
	 * @param tablecode
	 * @return
	 * @throws BusinessException
	 * 
	 */
	public String ConstructCountTargetSQL(String tablecode)
			throws BusinessException;

	/**
	 * Description : 构造查询数据sql语句
	 * 
	 * @param targetPanel
	 * @return
	 * @throws BusinessException
	 * 
	 */
	public String ConstructTargetSQL(ViewPanel targetPanel)
			throws BusinessException;

	/**
	 * Description : 构造过滤条件sql语句
	 * 
	 * @param searchPanel
	 * @param gridPanel
	 * @param inputMap
	 * @return
	 * @throws BusinessException
	 * 
	 */
	@SuppressWarnings("unchecked")
	public String ConstructConditionSQL(ViewPanel searchPanel,
			ViewPanel gridPanel, Map inputMap) throws BusinessException;

	/**
	 * Description : 构造排序sql语句
	 * 
	 * @param targetPanel
	 * @return
	 * @throws BusinessException
	 * 
	 */
	public String ConstructOrderBySQL(ViewPanel targetPanel)
			throws BusinessException;

	/**
	 * Description : 组装查询语句
	 * 
	 * @param tablecode
	 *            查询的表
	 * @param targetColumncodes
	 *            查询的字段集
	 * @param conditionColumncodes
	 *            需要过滤的字段
	 * @param inputMap
	 *            过滤条件参数
	 * @param orderColumncodes
	 *            排序字段集[columncode:ordertype{asc:升序;desc:倒序}]
	 * @return
	 * @throws BusinessException
	 * 
	 */
	public String ConstructSearchSQL(String tablecode,
			List<String> targetColumncodes,
			Map<String, Map<String, String[]>> conditionColumncodes,
			LinkedHashMap<String, String> orderColumncodes)
			throws BusinessException;
}
